package com.ruoyi.project.cyq.personnelManagement.personnel.controller;

import com.ruoyi.framework.web.controller.BaseController;

import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.cyq.personnelManagement.personnel.domain.Personnel;
import com.ruoyi.project.cyq.personnelManagement.personnel.service.IPersonnelService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


/**
 * @author ming
 * @date 2020-09-18 10:14
 * @desc 百战程序员 http://www.itbaizhan.com
 */
@Controller
@RequestMapping("/cyq/personnelManagement/personnel")
public class PersonnelController extends BaseController {

    //注入service
    @Autowired
    private IPersonnelService personnelService;

    //前缀
    private String prefix = "cyq/personnel";

    //控制器访问html网页
    @RequiresPermissions("cyq:personnel:view")
    @GetMapping()
    public String operlog() {
        return prefix + "/personnel";
    }

    /**
     * 内容的分页查询
     *  1.使用BaseController中的pageHelper进行分页
     *  2.调用service查询数据
     *  3.使用BaseController中的getDataTable(data)返回数据
     * @param personnel
     * @return
     */
    @RequiresPermissions("cyq:personnel:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Personnel personnel){

        System.out.println("进入controller！！！！！！！！");
        startPage();
        List<Personnel> data = personnelService.selectPersonnelLista(personnel);
        return getDataTable(data);
    }


}
